#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N = 2e5 + 10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
ll n, a[1010], pre[1010], suf[1010];
void solve()
{
    cin >> n;
    // pre[0]=1;
    // suf[n+1]=1;
    memset(pre, 0, sizeof pre);
    memset(suf, 0, sizeof suf);
    for(int i = 1; i <= n; i++) cin >> a[i];

    for(int i = 1; i <= n; i++)
    {
        if(a[i] == 2) pre[i] = pre[i - 1] + 1;
        else pre[i] = pre[i - 1];
    }

    for(int i = n; i >= 1; i--)
    {
        if(a[i] == 2) suf[i] = suf[i + 1] + 1;
        else suf[i] = suf[i + 1];
    }

    for(int i = 1; i < n; i++)
    {
        if(pre[i] == suf[i + 1])
        {
            cout << i << '\n';
            return;
        }
    }

    cout << -1 << '\n';


}

int main()
{
    close();
    int T;
    cin >> T;
    while (T--) solve();
    return 0;
}